/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package knn;

import java.util.List;
import knn.iris.IrisSample;
import knn.iris.IrisSampleLoader;
import knn.iris.Manhattan4Iris;

/**
 *
 * @author Nguyen Thuy Ngoc <ntngoc1988@gmail.com>
 */
public class knn {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String filename = "iris.data";
        List<IrisSample> result = IrisSampleLoader.load(filename);

        knnHelper<IrisSample> helper = new knnHelper<IrisSample>();
        helper.splitTrainingAndTestingSets(result, 0.9);

        IMetric<IrisSample> metric = new Manhattan4Iris();
        knnProcessor processor = new knnProcessor(helper.getTrainingSet(), metric, 5, new DefaultDominantSelector());

        for (IrisSample sample : helper.getTestingSet()) {
            String predictedClass = processor.predict(sample);

            System.out.println(
                    String.format("PredictedClass: %s\t\tTrueClass: %s",
                    predictedClass,
                    sample.getAssignedClass()));
        }
    }
}